from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Permission, ContentType
from meiduo_admin.serializers.permission import PermissionSerializer, ContentTypeSerializer
from meiduo_admin.utils import UserPageNum
from rest_framework.response import Response

class PermissionView(ModelViewSet):
    serializer_class = PermissionSerializer
    queryset = Permission.objects.all()
    pagination_class = UserPageNum

    def content_types(self,request):
        """
        获取权限类型数据
        :param request:
        :return:
        """
        #  查询全选分类
        content = ContentType.objects.all()

        ser = ContentTypeSerializer(content, many=True)
        return Response(ser.data)